<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<script type="text/javascript">
    seajs.use(["apps/grid"], function () {
        var uuid = "page-wrapper";
        var _pageComponent = new $.PageDomFactory(uuid);
        var pageListComponent = new $.PageListComponent(uuid, {
            view: {
                grid: "dg_org",
                myToolbar: "nsdb",
                colbar: "org_tempate"
            },
            configs: {
                gridTitle: "我的课题组",
                gridUrl: '${pageContext.request.contextPath}/app/api/organization/findMyOrg',
                gridColumns: [
                    {field: 'id', hidden: true},
                    {field: 'checkbox', checkbox: true},
                    {field: 'sysOrganization.orgName', title: '课题组名称', width: 140},
                    {field: 'sysOrganization.orgJobs', title: '备注', width: 140}
//                    {field: 'sysOrganization.available', title: '状态', width: 100,
//                        formatter: function (value, rec) {
//                            return value == "1" ? "启用" : "停用";
//                        }
//                    }
                ]
            },
            events: {
                renderColBarBefore: function (type, row) {
                    if (type == "manage"){
                        return row.role == 1;
                    }
                    return true;
                },
                onClickColBtn: function (context, btn, row) {
                    switch (btn.key) {
                        case "manage":
                            whenManage(context, btn.href, row);
                            break;
                        case "view":
                            whenView(context, row);
                            break;
                        default :
                            break;
                    }
                },
                onClickToolbarBtn: function (context, btn) {
                    switch (btn.key) {
                        case "search_all":
                            context.searchAll();
                            break;
                        case "search":
                            context.search(btn.href, "课题组搜索", "org_search");
                            break;
                        default :
                            break;
                    }
                }
            }
        });
        var contextWindow = new $.PageWindow();

        function whenView(context, row) {
//        var htm = [
//            {title: "课题组名称", value: "{{orgName}}"},
//            {title: "备注", value: "{{orgJobs}}"},
////            {title: "课题组编码", value: "{{orgCode}}"},
//            {title: "状态", value: "{{_available}}"}
//        ];
//        row._available = row.available == "1" ? "启用" : "停用";
            context.detail("课题组详情", row);
        }

        function whenManage(context, href, row) {
            contextWindow.create({
                href: href + "?id=" + row.sysOrganization.id,
                title: row.sysOrganization.orgName + "课题组成员管理",
                width: 960,
                height: 500
            });
            contextWindow.open();
        }

    });

</script>